package com.sc.sc250601.cook.service.impl;

import com.sc.sc250601.cook.mapper.NotificationMapper;
import com.sc.sc250601.cook.pojo.Notification;
import com.sc.sc250601.cook.service.NotificationService;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class NotificationServiceImpl implements NotificationService {

    @Autowired
    private NotificationMapper notificationMapper;

    // 查询用户的所有通知
    public List<Notification> getNotificationsByUserId(Long userId) {
        return notificationMapper.selectByUserId(userId);
    }

    // 标记单个通知为已读
    public void markAsRead(Long id) {
        notificationMapper.updateReadById(id);
    }

    // 标记用户所有通知为已读
    public void markAllAsRead(Long userId) {
        notificationMapper.updateAllReadByUserId(userId);
    }

    public int addNotification(Notification n) {
        return notificationMapper.insert(n);
    }

    public int addNotifications(List<Notification> ns) {
        return notificationMapper.addNotifications(ns);
    }
}